package com.xqx.dao.impl;

import com.xqx.dao.RoleDao;
import com.xqx.domain.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author：xingquanxiang createTime：2019/10/5 14:42
 * description:
 */
@Repository("roleDao")
public class RoleDaoImpl implements RoleDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    /**
     * 查询所有角色
     *
     * @return
     */
    @Override
    public List<Role> findAll() throws DataAccessException {
        return jdbcTemplate.query("select * from sys_role", new BeanPropertyRowMapper<Role>(Role.class));
    }
}
